import {Vector} from "./Vector";
import {IVector2} from "./types";

export class Vector2 extends Vector implements IVector2{
    constructor(x: number = 0, y: number = 0) {
        super(2);
        this.x = x;
        this.y = y;
    }

    set x(value: number) {
        this.data[0] = value;
    }
    get x() {
        return this.data[0];
    }
    set y(value: number) {
        this.data[1] = value;
    }
    get y() {
        return this.data[1];
    }

    added(t: Vector2) {
        return new Vector2(this.x + t.x, this.y + t.y);
    }


    subed(target: Vector2) {
        return new Vector2(this.x - target.x, this.y-target.y);
    }

    multiplied(scale: number) {
        return new Vector2(this.x * scale, this.y * scale);
    }
}